#!/usr/bin/env node

const cp=require('child_process');

let cat=cp.spawn('cat',['./data.txt']),
  sort=cp.spawn('sort'),
  uniq=cp.spawn('uniq');

//相当于执行命令cat data.txt | sort | uniq
cat.stdout.pipe(sort.stdin);
sort.stdout.pipe(uniq.stdin);
uniq.stdout.pipe(process.stdout);
uniq.stderr.pipe(process.stderr);
